<template>
  <!-- <mmbs-list :options="options"></mmbs-list> -->
  <yt-page title="企业信息" :rightData="rightData" :input="input" v-model="inputValue" @change="refresh">
    <yt-group :group="false" :searchApi="searchApi" ref="group">
      <yt-card slot-scope="item" :title="item.EnterpriseName" btn="查看更多内容" @btn-click="goDetailPage(item.id)" :tag="false">
        <p class="text-info">
          <span>企业类型:</span>
          <span class="m-r">{{item.EconomyType}}</span>
          <span>经营范围:</span>
          <span class="m-r">{{item.BusinessScope}}</span>
          <span>地址:</span>
          <span>{{item.LocationAddressDetails}}</span>
        </p>
      </yt-card>
    </yt-group>
  </yt-page>
</template>

<script>
// export default {
//   data() {
//     return {
//       options: {
//         global: {
//           title: '企业信息',
//           collectionName: 'ent_enterprise'
//         },
//         layout: 'card',
//         columns: [
//           {
//             label: '企业名称',
//             field: 'EnterpriseName',
//             isTitle: true,
//             hide: ['list']
//           },
//           {
//             label: '企业类型',
//             field: 'EconomyType'
//           },
//           {
//             label: '经营范围',
//             field: 'BusinessScope'
//           },
//           {
//             label: '地址',
//             field: 'LocationAddressDetails'
//           }
//         ]
//       }
//     }
//   },
//   created() {},
//   methods: {}
// }
import { commonApi } from '@/common/api/commonApi.js'
import { ReplaceDictionary } from '@/common/utils'

export default {
  data() {
    return {
      input: false,
      inputValue: '',
      rightData: [
        {
          font: 'yt-icon yt-icon-search',
          click: () => {
            this.input = !this.input
          }
        }
      ],
      searchApi: async ({ skip, limit }) => {
        let p = [
          commonApi.dictionary('enterprise_type'),
          commonApi.search('ent_enterprise', {
            contains: { EnterpriseName: this.inputValue }
          })
        ]
        let [dic, items] = await Promise.all(p)
        return ReplaceDictionary(items, { EconomyType: dic })
      }
    }
  },
  methods: {
    goDetailPage(id) {
      this.$router.$push({ path: '/company/detail', query: { id: id } })
    },
    refresh() {
      this.$refs.group.startPull()
    }
  }
}
</script>

<style scoped lang="stylus">
text-nowrap(line)
  display -webkit-box
  -webkit-box-orient vertical
  -webkit-line-clamp line
  overflow hidden

>>> .text-info
  color #aaa
  font-size 15px
  line-height 30px
  padding-left 10px
  padding-right 10px
  text-nowrap(2)
</style>
